<template>
  <div
    class="exhibits-content border-hover-style"
    :style="{ width: props.info.width + 'rem', height: props.info.height - 0.22 + 'rem' }"
  >
    <img class="boardleft" :src="publicUrls + 'free/style16/displayBoardStyle3Boardleft.webp'" alt="" />
    <div class="item-parent" v-for="(item, index) in props.info.showpieceList" :key="index">
      <div @contextmenu.stop="emit('onContextMenuChild', $event, index)" class="exhibits-item">
        <div class="cover-box" @click="viewImg(item.moduleId, item.id)">
          <img class="cover" :src="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')" alt="" />
          <img v-if="route.meta.loopType" class="flower-btn" :src="publicUrls + 'free/style2/flower.webp'" />
        </div>
        <div class="items-title">
          <p>{{ item.name }}</p>
        </div>
      </div>
    </div>
    <img class="boardleft" :src="publicUrls + 'free/style16/displayBoardStyle3Boardright.webp'" alt="" />
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free16Style3',
});
</script>

<script setup lang="ts">
import { urls, getLinkUrl } from '@/utils/request/upload';
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick, defineComponent } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { useRoute } from 'vue-router';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const route = useRoute();
const ImgVisible = ref(false);
const ImgUrl = ref('');

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});
const emitChildItemDraggable = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggable', draggingInfo, childIndex); //分组传递当前展品图距离相对父元素的xy偏移量变化
};
const emitChildItemDraggableStyle = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggableStyle', draggingInfo, childIndex); //分组设置当前展品图距离相对父元素的宽高变化
};
const emitShowcaseDraggable = (draggingInfo: any) => {
  emit('emitShowcaseDraggable', draggingInfo); //传递当前展柜图距离相对父元素的xy偏移量变化
};
const emitShowcaseDraggableStyle = (draggingInfo: any) => {
  emit('emitShowcaseDraggableStyle', draggingInfo); //传递当前展柜距离相对父元素的宽高变化
};

const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};

// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.info.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script>

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  padding: 0px !important;
  -webkit-box-reflect: below 60% linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

.active {
  :deep(.flot-menu) {
    display: flex;
  }
}
:deep(.active) {
  z-index: 999;
}
:deep(.vdr-handle) {
  z-index: 66;
}
.boardleft {
  width: 60px;
  height: 630px;
}
.item-parent {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 410px;
  height: 630px;
  background: url('https://static.jiyi.show/free/style16/displayBoardStyle3Bg.png') no-repeat center/100% 100%;
  flex-shrink: 0;
  .exhibits-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    padding-top: 62px;
  }
}
.cover-box {
  width: 229px;
  height: 306px;
  position: relative;
  margin-right: 3px;
  .cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
    background: #d9d9d9;
  }
}
.flower-btn {
  width: 40px;
  height: 40px;
  object-fit: cover;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: flower 2s linear infinite;
  @keyframes flower {
    0% {
      opacity: 0;
    }
    40% {
      opacity: 80%;
    }
    100% {
      opacity: 0;
    }
  }
}
.items-title {
  max-width: 180px;
  position: relative;
  margin-top: 52px;
  ::v-deep p {
    font-family: SourceHanSerifCN;
    font-size: 18px;
    color: #333;
    line-height: 32px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>
